package com.zmx.doctor.listener;

import android.content.Context;

/**
 * 程序猿：胖胖祥
 * 时 间：2020/9/3  22:56
 * 功 能：消息通知监听
 */
public class InformUpdateListenerManager {

    private MessageUpdateListener messageUpdateListener;
    private ChatListener chatListener;
    private Context mContext;
    private static InformUpdateListenerManager manager;

    public static InformUpdateListenerManager getInstance(Context context) {
        if (manager == null) {
            manager = new InformUpdateListenerManager(context);

        }
        return manager;
    }

    public InformUpdateListenerManager(Context context) {
        this.mContext = context.getApplicationContext();//使用getAppcationContext()防止单例模式内存泄漏
    }

    public void updateData() {

        if (messageUpdateListener != null) {
            messageUpdateListener.updateMessage();
        }
    }

    public void setInformUpdateListener(MessageUpdateListener informUpdateListener) {
        this.messageUpdateListener = informUpdateListener;
    }

    public void setChatListener(ChatListener chatListener) {
        this.chatListener = chatListener;
    }

    public void updateChat(String t_id) {

        if (messageUpdateListener != null) {
            chatListener.updateMessage(t_id);
        }
    }


}

